package org.example.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.example.pojo.entity.Order;
import org.example.pojo.entity.SaleLog;

import java.util.List;

@Mapper
public interface SalelogMapper {
    @Insert("insert into webwork.salelog(userid,username,goodid, goodname,  num, price, saletime,addressid,address,consignee) " +
            "VALUES (#{userid},#{username},#{goodid},#{goodname},#{num},#{price},#{saletime},#{addressid},#{address},#{consignee})")
    public void insertSaleLog(SaleLog saleLog);

    @Insert("insert into webwork.salelog(userid,username,goodid, goodname,  num, price, saletime,addressid,address,consignee,state) " +
            "VALUES (#{userid},#{username},#{goodid},#{goodname},#{num},#{price},#{saletime},#{addressid},#{address},#{consignee},#{state})")
    public void insertorder(Order order);

    @Update("update salelog set state = 1,addressid=#{addressid},address=#{address},consignee=#{consignee} where userid = #{userid} ")
    public void buySaleLog(SaleLog saleLog);

    @Update("update salelog set state = 0 where id = #{id}")
    public void cancelSaleLog(SaleLog saleLog);

    @Update("update salelog set num = #{num} where id = #{id}")
    public void addSaleLog(SaleLog saleLog1);

    public List<SaleLog> list(SaleLog saleLog);

    @Update("update salelog set num = #{num} where id = #{id}")
    public void update(SaleLog saleLog);
}
